# socket客户端
import socket
import threading

# 创建套接字
client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

def recv_data(client):
    while True:
        chunk = client.recv(1024)

        print(chunk.decode('utf-8'))

# 连接服务器
client.connect(('127.0.0.1', 1234))

# 接受输入
while True:
    data = input('请输入：')
    # 发送数据
    client.send(data.encode('utf-8'))
    
    thread = threading.Thread(target=recv_data, args=(client,))
    thread.start()


